<template>
  <li @mouseenter="isShow=true" @mouseleave="isShow=false">
    <label>
      <input  ref="ipt" type="checkbox" @change="chenckTodo(item.id)"  :checked="item.done" />
      <span>{{item.title}}</span>
    </label>
    <button v-show="isShow" class="btn btn-danger" @click="DeleteTodo(item.id)" >删除</button>
  </li>
</template>
<script>
export default {
  name: "VueDemoIndex",
  props:["item"],
  data(){
    return {
      isShow:false
    }
  },
  computed:{
    Todolist:{
      get(){
         return this.$store.state.TODOLIST
      },
    }
  },
  methods:{
    chenckTodo(id){
     this.$store.dispatch("checkTodo",{id,done:this.$refs.ipt.checked})
    },
    DeleteTodo(id){
      this.$store.dispatch("DeleteTodo",id)
    } 
  }
};
</script>

<style  scoped>
/*item*/
li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}

li label {
  float: left;
  cursor: pointer;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button {
  float: right;
  margin-top: 3px;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}



</style>